USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[PlayersSelectPlayerKillersTop5ByVictimPlayerId]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.PlayersSelectPlayerKillersTop5ByVictimPlayerId
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 09/03/08
-- Description:	Players Table Select - Top 5 Killers of a supplied Victim Player Id
-- =============================================
CREATE PROCEDURE PlayersSelectPlayerKillersTop5ByVictimPlayerId

            @Victim_PlayerId varchar(30)
	
AS

BEGIN

SELECT TOP 5 PlayerName, count(killid) as [Kills], PlayerId FROM Kills
INNER JOIN PlayerNameList ON Attacker_playerid = PlayerNameList.PlayerID
 where 
Victim_PlayerId = @Victim_PlayerId
group by Attacker_PlayerId, PlayerName, PlayerId
order by [Kills] DESC

END
GO



--  PlayersSelectPlayerKillersTop5ByVictimPlayerId 'STEAM_0:1:17834846'
